sinclude ../scripts/env.mk

ifeq ("$(origin G)", "command line")
ifeq ($(G),on)
X_CFLAGS	+= -O0 -g -ggdb
endif
endif

ARCH_NAME		:= i386
ARCH_DIR		:= arch/$(ARCH_NAME)

X_ASFLAGS	+= -f elf -I arch/include/
X_CFLAGS    += -fno-builtin -Wall -Wunused -fno-PIE -m32 -fno-stack-protector -O2 -D ARCH_I386
X_INCDIRS	+= include/ arch/include/
X_LDFLAGS	+= -no-pie -e kernel_start -Ttext 0x80100000

AS			:=	nasm
LD			:=  ld -m elf_i386
export AS LD

SRC			+= $(ARCH_DIR)/ *.c lib/ thread/ interrupt/

NAME		:= kernel.elf

define CUSTOM_TARGET_CMD
echo [KERNEL] $@; \
$(LD) $(X_LDFLAGS) -n -T $(ARCH_DIR)/kernel.ld -o $@ $(X_OBJS)
endef